<!DOCTYPE html>
<html lang="zh-cmn-Hans">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
		<title>我的地址</title>
		<link rel="stylesheet" href="../../css/ui.min.css" />
		<link rel="stylesheet" href="../../css/iconfont.css" />
		<link rel="stylesheet" href="../../css/shop.css" />
		<style>
			[v-clock]{display: none;}
		</style>
	</head>
	<body ontouchstart>
		<header class="ui-header">
			<a href="javascript:history.go(-1)" class="mui-action-back ui-icon hd-left">
				<span class="mui-action-back iconfont icon-fanhui"></span>
			</a>
			<div class="ui-title">我的地址</div>
			<a href="xinzeng-add.html" class="icon-text hd-right">添加新地址</a>
		</header>

		<div class="ui-content" id="app" v-clock>
			<div v-if="userinfo.length == 0" style="margin:0.5rem;">暂无收货地址</div>
			<div class="adds-cells">
				<div class="ui-cell ui-adds-cell" v-for="item in userinfo" @click="editAddr(item)">
					<div class="adds-icon">
						<img src="../../images/adsicon.png" alt="">
					</div>
					<div class="ui-cell__bd">
						<div class="ads-header">
							<span class="a-name">{{item.consignee}}</span><span class="a-tel">{{item.mobile}}</span>
						</div>
						<div class="ads-cont">
							<span class="tag" v-if="item.is_acquiesce_address==1">默认</span>{{item.province_name}}{{item.city_name}}{{item.district_name}}{{item.address}}
						</div>
					</div>
					<span class="ads-edit">编辑</span>
				</div>
			</div>
		</div>
		<script src="../../js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/mui.js"></script>
		<script src="../../js/vue.min.js"></script>
		<script src="../../js/common/config.js"></script>
		<script>
			// mui插件初始化
			mui.init();
			mui.plusReady(function() {
				vm.init();
			})
			
			var vm = new Vue({
				el: "#app",
				data: {
					userinfo:[],
				},
				methods: {
					init(){
						// step:1获取数据
						this.getData();
					},
					getData(){
						var _that = this;
						mui.ajax(Config.api.User_address_show, {
							data: {
								request_type: 1,
								user_id: localStorage.getItem('user_id'),
							},
							type: 'post',
							dataType: 'json',
							success: function(data) {
								if(data.success == 1){
									_that.userinfo = data.data;
								}
							},
							error: function(xhr, type, errorThrown) {
								console.log("接口错误");
							},
						});
					},
					editAddr(addr){
						var url = "./bianji-add.html";
						this.openWin(url,{addr:addr});
					},
					openWin(url, param = {}){
						mui.openWindow({
							url: url,
							id: url,
							styles: {
								top: '0px', //新页面顶部位置
								bottom: '0px', //新页面底部位置
								popGesture: 'close'
							},
							extras:param
						})
					}
				}
			});
			

		</script>
	</body>
</html>
